package com.mc.mcgoweb;

import com.mc.mcgoweb.vo.Student;
import io.swagger.annotations.Api;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.mc.entity.TestVo;

/***
 * @Description: TODO
 * @Date: 2019/3/1 10:42
 * @Author fmc
 */
@SpringBootApplication
@RestController
@RequestMapping("/mc")
@Api("订单管理")
public class McgoController {

    @RequestMapping(value = "/testController",method = RequestMethod.GET)
    public String test(String name){
        TestVo testVo=new TestVo();
        testVo.setName(name);
        testVo.setAge(88);
        return "TestJson success";
    }


    @RequestMapping(value = "/testStudent",method = RequestMethod.POST)
    public String testStudent(@RequestBody Student student) throws Exception {
        TestVo testVo=new TestVo();
        testVo.setName(student.getName());
        testVo.setAge(88);
        if (testVo!=null) {
            throw  new Exception("测试系统异常");
        }

        return "TestJson success";
    }

    @RequestMapping("/home1")
    public String home(ModelMap modelMap) {
        System.out.println(modelMap.get("author"));
        return "TestJson success";
    }


    @RequestMapping("/home")
    public String home(@ModelAttribute("author") String author) {
        System.out.println(author);
        return "TestJson success";
    }

}
